<?php if($sf_user->isAuthenticated()){ ?>
  <?php if($sf_user->getAttribute('suid')!=$author->getId()){ ?>
    <div id="divSubscribeUnsubscribe" style="width: 100px;margin-right: 10px;">
      <?php $array_subscriptions = preg_split('/[*]/', $array_suattr[6]); ?>
      <?php if(!in_array($author->getId(), $array_subscriptions)){/* si NO estoy suscrito */ ?>
        <a href="javascript:void(0)" onclick="ajaxSubscribe('<?php echo $author->getId() ?>')">
            <div class="suscripcion" style="display: block;">
                <div style="display: inline-block;vertical-align: middle;">Suscribirse</div>
                <div style="display: inline-block;vertical-align: middle;"><?php echo image_tag('tick.png','size=16x16') ?></div>
            </div></a>
      <?php }else{/* si estoy suscrito, puedo eliminar la suscripcion */ ?>
        <a href="javascript:void(0)" onclick="ajaxUnsubscribe('<?php echo $author->getId() ?>')">
            <div class="suscripcion" style="display: block;width: 110px;">
                <div style="display: inline-block;vertical-align: middle;">Anular suscripci&oacute;n</div>
                <div style="display: inline-block;vertical-align: middle;"><?php echo image_tag('delete.png','size=16x16') ?></div>
            </div></a>
      <?php } ?>
    </div>
  <?php } ?>
<?php } ?>
<script type="text/javascript">
function ajaxSubscribe(author_id){
    $.ajax({
        type: "post",
        url: "<?php echo url_for('@ajaxSubscribe') ?>",
        data: "id="+author_id,
        success: function(html){
            $("#divSubscribeUnsubscribe").html(html);
        }
    });
}
function ajaxUnsubscribe(author_id){
    $.ajax({
        type: "post",
        url: "<?php echo url_for('@ajaxUnsubscribe') ?>",
        data: "id="+author_id,
        success: function(html){
            $("#divSubscribeUnsubscribe").html(html);
        }
    });
}
</script>